package com.zzy.feignclient;

import com.zzy.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component // 要交给spring管理
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {

    @Override
    public UserService create(Throwable throwable) {
        throwable.printStackTrace();
        return new UserService() {
            @Override
            public User getUserById(Long id) {
                return new User(-1L, "触发熔断！", "服务不可用，请稍后重试！");
            }
        };
    }
}
